
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.pi4j.io.gpio.*;
import com.pi4j.io.gpio.Pin;
import com.pi4j.wiringpi.Gpio;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.text.ParseException;
import java.util.*;
import java.util.List;
import java.util.concurrent.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.*;

public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PumpTypePage = new javax.swing.JFrame();
        jButton14 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel23 = new javax.swing.JLabel();
        typefield = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        feqField = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        minspeedField = new javax.swing.JTextField();
        BumpBar2 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        pListInTypepage = new javax.swing.JTable();
        jButton17 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        PumpconfigMainFrame = new javax.swing.JFrame();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        BumpBar1 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        PumpTableInPumpPage = new javax.swing.JTable();
        jButton3 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        pumpNameField = new javax.swing.JTextField();
        jPanel16 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        pumpPin1 = new javax.swing.JComboBox<>();
        pin1Label = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        pumpPin2 = new javax.swing.JComboBox<>();
        pin2Label = new javax.swing.JLabel();
        pumpTypeBox = new javax.swing.JComboBox<>();
        jLabel13 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        pumpSpeed = new javax.swing.JSlider();
        speedDisplay = new javax.swing.JLabel();
        jButton19 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTabbedPane3 = new javax.swing.JTabbedPane();
        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        ActionConfiguationMainPage = new javax.swing.JFrame();
        jLabel7 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        PumpListInActionPage = new javax.swing.JTable();
        jButton6 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        AddBumpBar2 = new javax.swing.JPanel();
        jButton8 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        ActionTable = new javax.swing.JTable();
        jButton20 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        ActionDisplay = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem14 = new javax.swing.JMenuItem();
        PumpActionPageNew = new javax.swing.JFrame();
        SinglePumpAction = new javax.swing.JPanel();
        PumpComboBox = new javax.swing.JComboBox<>();
        jPanel18 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        endTimeInput = new javax.swing.JTextField();
        jPanel22 = new javax.swing.JPanel();
        jLabel28 = new javax.swing.JLabel();
        startTimeInput = new javax.swing.JTextField();
        pumpActionSpeed = new javax.swing.JSlider();
        pumpActionSpeedDisplay = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        actionReversed = new javax.swing.JToggleButton();
        jButton16 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        PumpActionEditPage = new javax.swing.JFrame();
        SinglePumpAction2 = new javax.swing.JPanel();
        PumpComboBox2 = new javax.swing.JComboBox<>();
        jPanel21 = new javax.swing.JPanel();
        jLabel31 = new javax.swing.JLabel();
        endTimeInput2 = new javax.swing.JTextField();
        jPanel25 = new javax.swing.JPanel();
        jLabel32 = new javax.swing.JLabel();
        startTimeInput2 = new javax.swing.JTextField();
        pumpActionSpeed2 = new javax.swing.JSlider();
        pumpActionSpeedDisplay2 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        actionReversed2 = new javax.swing.JToggleButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        PumpActionPageNewLoop = new javax.swing.JFrame();
        SinglePumpAction1 = new javax.swing.JPanel();
        PumpComboBox1 = new javax.swing.JComboBox<>();
        jPanel19 = new javax.swing.JPanel();
        jLabel20 = new javax.swing.JLabel();
        endTimeInput1 = new javax.swing.JTextField();
        jPanel23 = new javax.swing.JPanel();
        jLabel29 = new javax.swing.JLabel();
        startTimeInput1 = new javax.swing.JTextField();
        pumpActionSpeed1 = new javax.swing.JSlider();
        pumpActionSpeedDisplay1 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        actionReversed1 = new javax.swing.JToggleButton();
        jPanel24 = new javax.swing.JPanel();
        jLabel30 = new javax.swing.JLabel();
        runInterval = new javax.swing.JTextField();
        jPanel20 = new javax.swing.JPanel();
        jLabel27 = new javax.swing.JLabel();
        stopInterval = new javax.swing.JTextField();
        jButton22 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        ActionExpertMode = new javax.swing.JFrame();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        PumpListInExpertMode = new javax.swing.JTable();
        jLabel11 = new javax.swing.JLabel();
        jPanel11 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        expertSlider = new javax.swing.JSlider();
        reversButton = new javax.swing.JToggleButton();
        speedDisplayExpert = new javax.swing.JLabel();
        Stopbtn = new javax.swing.JButton();
        runButton = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jLabel33 = new javax.swing.JLabel();
        FileChooser = new javax.swing.JFrame();
        Save = new javax.swing.JFileChooser();
        Load = new javax.swing.JFileChooser();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        PumpTypePage.setTitle("newType");
        PumpTypePage.setSize(new java.awt.Dimension(580, 480));

        jButton14.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton14.setText("Next>");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jButton18.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton18.setText("Add");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Arial", 2, 18)); // NOI18N
        jLabel21.setText("Edit Pump Type ");

        jLabel23.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel23.setText("Name:");

        jLabel24.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel24.setText("Frequency:");

        jLabel25.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel25.setText("Minspeed:");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addGap(10, 10, 10)
                        .addComponent(minspeedField))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(typefield, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(feqField, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(typefield, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(feqField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(minspeedField, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        BumpBar2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "TypeList", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 18))); // NOI18N

        pListInTypepage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        pListInTypepage.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Name", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        pListInTypepage.getColumnModel().getColumn(0).setMaxWidth(150);
        jScrollPane7.setViewportView(pListInTypepage);

        jButton17.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        jButton17.setText("-");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout BumpBar2Layout = new javax.swing.GroupLayout(BumpBar2);
        BumpBar2.setLayout(BumpBar2Layout);
        BumpBar2Layout.setHorizontalGroup(
            BumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, BumpBar2Layout.createSequentialGroup()
                .addGap(207, 207, 207)
                .addComponent(jButton17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        BumpBar2Layout.setVerticalGroup(
            BumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BumpBar2Layout.createSequentialGroup()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/Type.png"))); // NOI18N

        javax.swing.GroupLayout PumpTypePageLayout = new javax.swing.GroupLayout(PumpTypePage.getContentPane());
        PumpTypePage.getContentPane().setLayout(PumpTypePageLayout);
        PumpTypePageLayout.setHorizontalGroup(
            PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpTypePageLayout.createSequentialGroup()
                .addGroup(PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PumpTypePageLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(BumpBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PumpTypePageLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(PumpTypePageLayout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addComponent(jButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(PumpTypePageLayout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGap(12, 12, 12))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpTypePageLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        PumpTypePageLayout.setVerticalGroup(
            PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpTypePageLayout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PumpTypePageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PumpTypePageLayout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(30, 30, 30)
                        .addComponent(jButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(BumpBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11))
        );

        BumpBar2.getAccessibleContext().setAccessibleDescription("");

        PumpconfigMainFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        PumpconfigMainFrame.setTitle("PumpConfig");
        PumpconfigMainFrame.setAutoRequestFocus(false);
        PumpconfigMainFrame.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        PumpconfigMainFrame.setFocusable(false);
        PumpconfigMainFrame.setLocation(new java.awt.Point(0, 0));
        PumpconfigMainFrame.setSize(new java.awt.Dimension(1100, 585));

        jTabbedPane2.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N

        jPanel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

        BumpBar1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PumpList", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 18))); // NOI18N

        PumpTableInPumpPage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        PumpTableInPumpPage.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PumpName", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        PumpTableInPumpPage.getColumnModel().getColumn(0).setMaxWidth(300);
        jScrollPane4.setViewportView(PumpTableInPumpPage);

        jButton3.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/delete.png"))); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout BumpBar1Layout = new javax.swing.GroupLayout(BumpBar1);
        BumpBar1.setLayout(BumpBar1Layout);
        BumpBar1Layout.setHorizontalGroup(
            BumpBar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, BumpBar1Layout.createSequentialGroup()
                .addGroup(BumpBar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(BumpBar1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE))
                .addContainerGap())
        );
        BumpBar1Layout.setVerticalGroup(
            BumpBar1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BumpBar1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PumpConfiguation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 18))); // NOI18N

        jLabel12.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/positive.png"))); // NOI18N
        jLabel12.setText("Pos:");

        pumpPin1.setAutoscrolls(true);
        pumpPin1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                pumpPin1ItemStateChanged(evt);
            }
        });

        pin1Label.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        pin1Label.setText("select");

        jLabel26.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/negative.png"))); // NOI18N
        jLabel26.setText("Neg:");

        pumpPin2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                pumpPin2ItemStateChanged(evt);
            }
        });

        pin2Label.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        pin2Label.setText("select");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel26, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pumpPin2, 0, 145, Short.MAX_VALUE)
                    .addComponent(pumpPin1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pin1Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pin2Label, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pumpPin1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pin1Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel12))
                .addGap(18, 18, 18)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pumpPin2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pin2Label)
                    .addComponent(jLabel26))
                .addContainerGap())
        );

        pumpTypeBox.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        pumpTypeBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "QW" }));
        pumpTypeBox.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        pumpTypeBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pumpTypeBoxActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/EditType.png"))); // NOI18N
        jLabel13.setText("Type:");

        jLabel9.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/name.png"))); // NOI18N
        jLabel9.setText("Name: ");

        jLabel10.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/speedometer.png"))); // NOI18N
        jLabel10.setText("MaxSpeed:");

        pumpSpeed.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        pumpSpeed.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        pumpSpeed.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pumpSpeedStateChanged(evt);
            }
        });

        speedDisplay.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        speedDisplay.setText("50");

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel16, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pumpNameField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pumpTypeBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pumpSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(speedDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(6, 6, 6))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel14Layout.createSequentialGroup()
                                .addComponent(pumpTypeBox, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pumpNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pumpSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(speedDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pumpTypeBox.getAccessibleContext().setAccessibleName("");

        jButton19.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/EditType.png"))); // NOI18N
        jButton19.setText("EditType");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        jButton15.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/add.png"))); // NOI18N
        jButton15.setText("Add");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton19, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
                    .addComponent(jButton15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jButton2.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/next.png"))); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BumpBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(BumpBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28))))
        );

        jTabbedPane2.addTab("Standard", jPanel3);
        jTabbedPane2.addTab("Advnced", jTabbedPane3);

        jLabel5.setFont(new java.awt.Font("Arial", 2, 18)); // NOI18N
        jLabel5.setText("Pump Configuation Page");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/home.png"))); // NOI18N

        javax.swing.GroupLayout PumpconfigMainFrameLayout = new javax.swing.GroupLayout(PumpconfigMainFrame.getContentPane());
        PumpconfigMainFrame.getContentPane().setLayout(PumpconfigMainFrameLayout);
        PumpconfigMainFrameLayout.setHorizontalGroup(
            PumpconfigMainFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpconfigMainFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PumpconfigMainFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jTabbedPane2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addContainerGap())
        );
        PumpconfigMainFrameLayout.setVerticalGroup(
            PumpconfigMainFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpconfigMainFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PumpconfigMainFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PumpconfigMainFrameLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(PumpconfigMainFrameLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(19, 19, 19)
                        .addComponent(jTabbedPane2)
                        .addGap(17, 17, 17))))
        );

        ActionConfiguationMainPage.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        ActionConfiguationMainPage.setTitle("ActionConfig");
        ActionConfiguationMainPage.setLocation(new java.awt.Point(0, 0));
        ActionConfiguationMainPage.setSize(new java.awt.Dimension(1200, 560));

        jLabel7.setFont(new java.awt.Font("Arial", 2, 18)); // NOI18N
        jLabel7.setText("Action Page");

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Pumps:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 18))); // NOI18N
        jPanel7.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N

        PumpListInActionPage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        PumpListInActionPage.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Pump1", "GPIO(12.13) 100% "},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "PumpName", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        PumpListInActionPage.getColumnModel().getColumn(0).setMaxWidth(300);
        jScrollPane5.setViewportView(PumpListInActionPage);

        jButton6.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/edit.png"))); // NOI18N
        jButton6.setText("Edit");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton4.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/expertMode.png"))); // NOI18N
        jButton4.setText("expert >");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(17, 17, 17))))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        AddBumpBar2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Actions:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 18))); // NOI18N

        jButton8.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/add.png"))); // NOI18N
        jButton8.setText("New");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton12.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/delete.png"))); // NOI18N
        jButton12.setText("-");
        jButton12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton12MouseClicked(evt);
            }
        });
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        ActionTable.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        ActionTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"SingleAction", "Pump 1 run * sec ", null},
                {"WaitingPumpAction", "After Pump 1 stop Pump 2 run * sec", null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Action", "Content", "Active"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        ActionTable.getColumnModel().getColumn(0).setMinWidth(30);
        ActionTable.getColumnModel().getColumn(1).setMinWidth(600);
        ActionTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ActionTableMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(ActionTable);

        jButton20.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N
        jButton20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/stop.png"))); // NOI18N
        jButton20.setText("Stop");
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });

        jButton10.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N
        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/play.png"))); // NOI18N
        jButton10.setText("Run");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton5.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N
        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/loop.png"))); // NOI18N
        jButton5.setText("Loops");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton7.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/delete.png"))); // NOI18N
        jButton7.setText("All");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton11.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N
        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/edit.png"))); // NOI18N
        jButton11.setText("Edit");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout AddBumpBar2Layout = new javax.swing.GroupLayout(AddBumpBar2);
        AddBumpBar2.setLayout(AddBumpBar2Layout);
        AddBumpBar2Layout.setHorizontalGroup(
            AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AddBumpBar2Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14))
            .addGroup(AddBumpBar2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2)
                    .addGroup(AddBumpBar2Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton20, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        AddBumpBar2Layout.setVerticalGroup(
            AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, AddBumpBar2Layout.createSequentialGroup()
                .addGroup(AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(AddBumpBar2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(AddBumpBar2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton20, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(28, 28, 28))
                    .addGroup(AddBumpBar2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        ActionDisplay.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/ActionPage.png"))); // NOI18N

        jMenu3.setText("Save");
        jMenu3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N

        jMenuItem15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/save.png"))); // NOI18N
        jMenuItem15.setText("Save Config");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem15ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem15);

        jMenuBar2.add(jMenu3);

        jMenu4.setText("Load");
        jMenu4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N

        jMenuItem14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/load.png"))); // NOI18N
        jMenuItem14.setText("Load Config");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem14);

        jMenuBar2.add(jMenu4);

        ActionConfiguationMainPage.setJMenuBar(jMenuBar2);

        javax.swing.GroupLayout ActionConfiguationMainPageLayout = new javax.swing.GroupLayout(ActionConfiguationMainPage.getContentPane());
        ActionConfiguationMainPage.getContentPane().setLayout(ActionConfiguationMainPageLayout);
        ActionConfiguationMainPageLayout.setHorizontalGroup(
            ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                .addGroup(ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18))
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGroup(ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addComponent(AddBumpBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22))
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addComponent(ActionDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 611, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6)
                        .addGap(30, 30, 30))))
        );
        ActionConfiguationMainPageLayout.setVerticalGroup(
            ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                .addGroup(ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ActionDisplay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel7)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ActionConfiguationMainPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18))
                    .addGroup(ActionConfiguationMainPageLayout.createSequentialGroup()
                        .addComponent(AddBumpBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(20, Short.MAX_VALUE))))
        );

        jPanel7.getAccessibleContext().setAccessibleDescription("");

        PumpActionPageNew.setTitle("newAction");
        PumpActionPageNew.setBackground(new java.awt.Color(0, 0, 0));
        PumpActionPageNew.setLocation(new java.awt.Point(0, 0));
        PumpActionPageNew.setMinimumSize(new java.awt.Dimension(468, 300));
        PumpActionPageNew.setSize(new java.awt.Dimension(630, 350));

        SinglePumpAction.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SinglePumpAction:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 2, 18))); // NOI18N

        PumpComboBox.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        PumpComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Pump 1 " }));

        jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel19.setText("End Time:");

        endTimeInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endTimeInputActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(36, 36, 36)
                .addComponent(endTimeInput, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(endTimeInput)
        );

        jLabel28.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel28.setText("Start Time:");

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(30, 30, 30)
                .addComponent(startTimeInput, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(startTimeInput)
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(3, 3, 3))
        );

        pumpActionSpeed.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pumpActionSpeedStateChanged(evt);
            }
        });

        pumpActionSpeedDisplay.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        pumpActionSpeedDisplay.setText("50");

        jLabel15.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel15.setText("Speed:");

        actionReversed.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        actionReversed.setText("Reversed");
        actionReversed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                actionReversedActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout SinglePumpActionLayout = new javax.swing.GroupLayout(SinglePumpAction);
        SinglePumpAction.setLayout(SinglePumpActionLayout);
        SinglePumpActionLayout.setHorizontalGroup(
            SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpActionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpActionLayout.createSequentialGroup()
                        .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(PumpComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(SinglePumpActionLayout.createSequentialGroup()
                                .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(actionReversed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(pumpActionSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(34, 34, 34))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpActionLayout.createSequentialGroup()
                        .addComponent(pumpActionSpeedDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(57, 57, 57))))
        );
        SinglePumpActionLayout.setVerticalGroup(
            SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpActionLayout.createSequentialGroup()
                .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SinglePumpActionLayout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(PumpComboBox)
                        .addGap(36, 36, 36))
                    .addGroup(SinglePumpActionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpActionLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(actionReversed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(SinglePumpActionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pumpActionSpeed, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pumpActionSpeedDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );

        jButton16.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/back.png"))); // NOI18N
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        jButton13.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/confirming.png"))); // NOI18N
        jButton13.setText("Save");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/newAction.png"))); // NOI18N

        javax.swing.GroupLayout PumpActionPageNewLayout = new javax.swing.GroupLayout(PumpActionPageNew.getContentPane());
        PumpActionPageNew.getContentPane().setLayout(PumpActionPageNewLayout);
        PumpActionPageNewLayout.setHorizontalGroup(
            PumpActionPageNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpActionPageNewLayout.createSequentialGroup()
                .addGroup(PumpActionPageNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(PumpActionPageNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(PumpActionPageNewLayout.createSequentialGroup()
                                .addComponent(jButton16, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                                .addGap(370, 370, 370)
                                .addComponent(jButton13, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
                            .addComponent(SinglePumpAction, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel8)))
                .addContainerGap())
        );
        PumpActionPageNewLayout.setVerticalGroup(
            PumpActionPageNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SinglePumpAction, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PumpActionPageNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PumpActionPageNewLayout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jButton13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        PumpActionEditPage.setTitle("newAction");
        PumpActionEditPage.setLocation(new java.awt.Point(0, 0));
        PumpActionEditPage.setMinimumSize(new java.awt.Dimension(468, 300));
        PumpActionEditPage.setSize(new java.awt.Dimension(600, 350));

        SinglePumpAction2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "EditAction:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 2, 18))); // NOI18N

        PumpComboBox2.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        PumpComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Pump 1 " }));

        jLabel31.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel31.setText("End Time:");

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(36, 36, 36)
                .addComponent(endTimeInput2, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(endTimeInput2)
        );

        jLabel32.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel32.setText("Start Time:");

        javax.swing.GroupLayout jPanel25Layout = new javax.swing.GroupLayout(jPanel25);
        jPanel25.setLayout(jPanel25Layout);
        jPanel25Layout.setHorizontalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel25Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel32, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(30, 30, 30)
                .addComponent(startTimeInput2, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel25Layout.setVerticalGroup(
            jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel25Layout.createSequentialGroup()
                .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(startTimeInput2)
                    .addGroup(jPanel25Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel32, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(3, 3, 3))
        );

        pumpActionSpeed2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pumpActionSpeed2StateChanged(evt);
            }
        });

        pumpActionSpeedDisplay2.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        pumpActionSpeedDisplay2.setText("50");

        jLabel17.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel17.setText("Speed:");

        actionReversed2.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        actionReversed2.setText("Reversed");
        actionReversed2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                actionReversed2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout SinglePumpAction2Layout = new javax.swing.GroupLayout(SinglePumpAction2);
        SinglePumpAction2.setLayout(SinglePumpAction2Layout);
        SinglePumpAction2Layout.setHorizontalGroup(
            SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpAction2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpAction2Layout.createSequentialGroup()
                        .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(PumpComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(SinglePumpAction2Layout.createSequentialGroup()
                                .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(actionReversed2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(pumpActionSpeed2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(34, 34, 34))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpAction2Layout.createSequentialGroup()
                        .addComponent(pumpActionSpeedDisplay2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(57, 57, 57))))
        );
        SinglePumpAction2Layout.setVerticalGroup(
            SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpAction2Layout.createSequentialGroup()
                .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SinglePumpAction2Layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(PumpComboBox2)
                        .addGap(36, 36, 36))
                    .addGroup(SinglePumpAction2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SinglePumpAction2Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(actionReversed2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(SinglePumpAction2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pumpActionSpeed2, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pumpActionSpeedDisplay2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );

        jButton24.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/back.png"))); // NOI18N
        jButton24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton24ActionPerformed(evt);
            }
        });

        jButton25.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/confirming.png"))); // NOI18N
        jButton25.setText("Save");
        jButton25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton25ActionPerformed(evt);
            }
        });

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/edit.png"))); // NOI18N

        javax.swing.GroupLayout PumpActionEditPageLayout = new javax.swing.GroupLayout(PumpActionEditPage.getContentPane());
        PumpActionEditPage.getContentPane().setLayout(PumpActionEditPageLayout);
        PumpActionEditPageLayout.setHorizontalGroup(
            PumpActionEditPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PumpActionEditPageLayout.createSequentialGroup()
                .addGroup(PumpActionEditPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionEditPageLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(PumpActionEditPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(PumpActionEditPageLayout.createSequentialGroup()
                                .addComponent(jButton24, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                                .addGap(370, 370, 370)
                                .addComponent(jButton25, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE))
                            .addComponent(SinglePumpAction2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionEditPageLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel14)))
                .addContainerGap())
        );
        PumpActionEditPageLayout.setVerticalGroup(
            PumpActionEditPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionEditPageLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SinglePumpAction2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(PumpActionEditPageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PumpActionEditPageLayout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jButton25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton24, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        PumpActionPageNewLoop.setTitle("newAction");
        PumpActionPageNewLoop.setLocation(new java.awt.Point(0, 0));
        PumpActionPageNewLoop.setMinimumSize(new java.awt.Dimension(468, 300));
        PumpActionPageNewLoop.setSize(new java.awt.Dimension(700, 400));

        SinglePumpAction1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "LoopPumpAction:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 2, 18))); // NOI18N

        PumpComboBox1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        PumpComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Pump 1 " }));

        jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel20.setText("End Time:");

        endTimeInput1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endTimeInput1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(41, 41, 41)
                .addComponent(endTimeInput1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(endTimeInput1)
        );

        jLabel29.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel29.setText("Start Time:");

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel29, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)
                .addGap(30, 30, 30)
                .addComponent(startTimeInput1, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(startTimeInput1)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel29, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(3, 3, 3))
        );

        pumpActionSpeed1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pumpActionSpeed1StateChanged(evt);
            }
        });

        pumpActionSpeedDisplay1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        pumpActionSpeedDisplay1.setText("50");

        jLabel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel16.setText("Speed:");

        actionReversed1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        actionReversed1.setText("Reversed");
        actionReversed1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                actionReversed1ActionPerformed(evt);
            }
        });

        jLabel30.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel30.setText("Run Interval:");

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(30, 30, 30)
                .addComponent(runInterval, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel24Layout.createSequentialGroup()
                .addGroup(jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(runInterval)
                    .addGroup(jPanel24Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jLabel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(3, 3, 3))
        );

        jLabel27.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel27.setText("Stop Interval:");

        stopInterval.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopIntervalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(27, 27, 27)
                .addComponent(stopInterval, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(stopInterval)
        );

        javax.swing.GroupLayout SinglePumpAction1Layout = new javax.swing.GroupLayout(SinglePumpAction1);
        SinglePumpAction1.setLayout(SinglePumpAction1Layout);
        SinglePumpAction1Layout.setHorizontalGroup(
            SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                        .addComponent(PumpComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                                .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, Short.MAX_VALUE)
                                .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                        .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pumpActionSpeed1, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(pumpActionSpeedDisplay1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(actionReversed1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        SinglePumpAction1Layout.setVerticalGroup(
            SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SinglePumpAction1Layout.createSequentialGroup()
                        .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(PumpComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(SinglePumpAction1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pumpActionSpeed1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pumpActionSpeedDisplay1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(actionReversed1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton22.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/back.png"))); // NOI18N
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });

        jButton23.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/confirming.png"))); // NOI18N
        jButton23.setText("Save");
        jButton23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton23ActionPerformed(evt);
            }
        });

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/loop.png"))); // NOI18N

        javax.swing.GroupLayout PumpActionPageNewLoopLayout = new javax.swing.GroupLayout(PumpActionPageNewLoop.getContentPane());
        PumpActionPageNewLoop.getContentPane().setLayout(PumpActionPageNewLoopLayout);
        PumpActionPageNewLoopLayout.setHorizontalGroup(
            PumpActionPageNewLoopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLoopLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PumpActionPageNewLoopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(PumpActionPageNewLoopLayout.createSequentialGroup()
                        .addComponent(SinglePumpAction1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(PumpActionPageNewLoopLayout.createSequentialGroup()
                        .addComponent(jButton22, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton23, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLoopLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel18)
                .addContainerGap())
        );
        PumpActionPageNewLoopLayout.setVerticalGroup(
            PumpActionPageNewLoopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PumpActionPageNewLoopLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SinglePumpAction1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(25, 25, 25)
                .addGroup(PumpActionPageNewLoopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton22, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton23, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17))
        );

        ActionExpertMode.setTitle("Expert");
        ActionExpertMode.setSize(new java.awt.Dimension(920, 500));

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Pumps:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 24))); // NOI18N

        PumpListInExpertMode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        PumpListInExpertMode.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                { new Integer(1), "Pump1", "QW/GPIO(12,13)/100%", null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Index", "PumpName", "Status", "On"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        this.PumpListInExpertMode.getColumnModel().getColumn(0).setMinWidth(30);
        this.PumpListInExpertMode.getColumnModel().getColumn(1).setMinWidth(50);
        this.PumpListInExpertMode.getColumnModel().getColumn(2).setMinWidth(600);
        PumpListInExpertMode.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                PumpListInExpertModeMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                PumpListInExpertModeMousePressed(evt);
            }
        });
        jScrollPane6.setViewportView(PumpListInExpertMode);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel11.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 153, 51));
        jLabel11.setText("Expert Mode");

        jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, java.awt.Color.gray));

        jLabel22.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel22.setText("Speed:");

        expertSlider.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                expertSliderStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(expertSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(expertSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        reversButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        reversButton.setText("Run/Reverse");
        reversButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reversButtonActionPerformed(evt);
            }
        });

        speedDisplayExpert.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        speedDisplayExpert.setText("50");

        Stopbtn.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        Stopbtn.setText("Stop");
        Stopbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StopbtnActionPerformed(evt);
            }
        });

        runButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        runButton.setText("Run");
        runButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGap(413, 413, 413)
                        .addComponent(speedDisplayExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(48, 48, 48)))
                .addComponent(reversButton, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(Stopbtn, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(runButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(reversButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(speedDisplayExpert, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(runButton, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(Stopbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jButton9.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/back.png"))); // NOI18N
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton21.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton21.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/stop.png"))); // NOI18N
        jButton21.setText("All");
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });

        jLabel33.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/expertMode.png"))); // NOI18N

        javax.swing.GroupLayout ActionExpertModeLayout = new javax.swing.GroupLayout(ActionExpertMode.getContentPane());
        ActionExpertMode.getContentPane().setLayout(ActionExpertModeLayout);
        ActionExpertModeLayout.setHorizontalGroup(
            ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ActionExpertModeLayout.createSequentialGroup()
                .addGroup(ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(ActionExpertModeLayout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel33))
                    .addGroup(ActionExpertModeLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, ActionExpertModeLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton21, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(360, 360, 360)
                        .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)))
                .addGap(22, 22, 22))
        );
        ActionExpertModeLayout.setVerticalGroup(
            ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ActionExpertModeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel33)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ActionExpertModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton21, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                    .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(40, 40, 40))
        );

        FileChooser.setSize(new java.awt.Dimension(586, 412));
        FileChooser.setType(java.awt.Window.Type.POPUP);

        Save.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);

        javax.swing.GroupLayout FileChooserLayout = new javax.swing.GroupLayout(FileChooser.getContentPane());
        FileChooser.getContentPane().setLayout(FileChooserLayout);
        FileChooserLayout.setHorizontalGroup(
            FileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FileChooserLayout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(Load, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE))
            .addGroup(FileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(FileChooserLayout.createSequentialGroup()
                    .addGap(18, 18, 18)
                    .addComponent(Save, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(18, 18, 18)))
        );
        FileChooserLayout.setVerticalGroup(
            FileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FileChooserLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Load, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(FileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(FileChooserLayout.createSequentialGroup()
                    .addGap(6, 6, 6)
                    .addComponent(Save, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(6, 6, 6)))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setLocation(new java.awt.Point(100, 100));
        setSize(new java.awt.Dimension(587, 582));

        jButton1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/icons/chip.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel1.setText("Lab on Chip");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(245, 245, 245)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 531, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleName("WelcomeFrame");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        this.PumpconfigMainFrame.setVisible(true);
        
        
//        Log("Avaliable Types :"+ Arrays.toString(this.typelist.toArray()));
        //添加默认Pumptype
//        PumpType t = new PumpType("RP-Q1.2N-P20Z-DC3V",100,10);
//        typelist.add(t);

        //添加默认Pump
//        Pump p1 = new Pump("p1",t,100,15,16);
//        Pump p2 = new Pump("p2",t,100,24,25);
//        Pump p3 = new Pump("p3",t,100,28,29);
//        Pump p4 = new Pump("p4",t,100,26,27);
//        
//        this.pumpList.add(p1);
//        this.pumpList.add(p2);
//        this.pumpList.add(p3);
//        this.pumpList.add(p4);
//
//        //添加默认Actions
//        Action a = new Action(0,0,1,90,p1,false );
//        this.actionList.add(a);
        
        jMenuItem14ActionPerformed( evt);
        this.mapTypeListToTable(this.pListInTypepage,typelist);
       //安排slider
       
        loadPumpconfigFrame();
        
        
    }//GEN-LAST:event_jButton1ActionPerformed

    //为slider设置刻度
    private  void setTS(JSlider slider){
        slider.setMajorTickSpacing(5);
        slider.setMinorTickSpacing(1);
        slider.setPaintTicks(true);

    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        ActionConfiguationMainPage.setVisible(true);
        this.PumpconfigMainFrame.setVisible(false);
        ////先清空table
        this.mapPumplistToTable(PumpListInActionPage);

        //检查action里面有没有多余pump如果有则删掉
        ////还需要debug***********************************
//        for(int j = 0; j < this.actionList.size() ; j++){
//            if(this.actionList.size() == 0) {
//                break;
//            }
//            Action a = this.actionList.get(j);
//            for(int i = 0 ; i < this.pumpList.size() ; i++ ){
//                if(this.pumpList.get(i).getName().equals(a.getP().getName())){
//                    continue;
//                }
//                if(i == this.pumpList.size()-1){
//                    this.actionList.remove(a);
//                }
//            }
//        }
        /////
        updateActionListToTable(ActionTable);

//        showTypeList();
//        showPumpList();
//        showActionList();
    }//GEN-LAST:event_jButton2ActionPerformed
    
    private void clearTableContent(JTable tab){
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        model.setRowCount(0);
    }


    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        this.PumpActionPageNew.setVisible(true);
        // 更新pumplist in combobox、
        this.PumpComboBox.removeAllItems();
        
        for(int i = 0 ; i< this.pumpList.size();i++){
             this.PumpComboBox.addItem(""+pumpList.get(i).getName());
        }
        this.startTimeInput.setText("00:00:000");
        this.endTimeInput.setText("00:02:000");
        
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

       this.ActionExpertMode.setVisible(true);
       
       updatepumpListOnExpertTable();
       
       setTS(expertSlider);
       reversButton.setText("Normal");
       this.showPumpList();
       
    }//GEN-LAST:event_jButton4ActionPerformed

    void updatepumpListOnExpertTable(){
        this.clearTableContent(PumpListInExpertMode);
       //更新table
       for(int i = 0 ; i < this.pumpList.size(); i++){
           Pump p = pumpList.get(i);
            ArrayList<String> content = new ArrayList<String>();
            content.add(""+i);
            content.add(p.getName());
            content.add(p.toString());
            content.add(p.isActive? "true": "false");
            DefaultTableModel model = (DefaultTableModel) PumpListInExpertMode.getModel();
            model.addRow(content.toArray());
       }
    }
    
    
    
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        this.ActionExpertMode.setVisible(false);
    }//GEN-LAST:event_jButton9ActionPerformed
    //Run所有的pump

    ScheduledExecutorService worldTime;
    
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        //pumplist里的pump逐一运行
        this.jButton10.setEnabled(false);
//        String message = "Program Now Running !";
//        javax.swing.JOptionPane.showMessageDialog(this, message);
//        Gpio.wiringPiSetup();
//        for(Pump p : pumpList){
//            p.provisionPin(p.getPinNumber1(), 0 ,10);
//            p.provisionPin(p.getPinNumber2(), 0 ,10);
//            p.start(p.getPinNumber1(), 0);
//            p.start(p.getPinNumber2(), 0);
//            p.shutdown();
//        }
        //开始时间线程序
        //测试逻辑1
        //开始无限循环并记录当前运行时间
        //遍历所有actionlist检查所有的action 的delaytime
        //如果当前运行时间等于delaytime则该action开始运行
        //如果当前运行时间等于delaytime+runtime 则从list里移除。
        //跳出循环直到list为空、

        //测试逻辑2
        //使用schedueled excuterservice 将其添加进Action类里
        //遍历一次list然后启动所有的executer service.

        //////测试逻辑3
        ArrayList<Action> executeList = new ArrayList<>();
        for (Pump p : pumpList){
            p.initEq();
            try {
                executeList.add(p.getEq().remove());
            }catch (Exception e ){
                Log(p.getName()+ "isEmpty");
            }

        }
        
        worldTime = Executors.newScheduledThreadPool(1);
        
        
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer() {
                    public Component getTableCellRendererComponent(JTable table,
                                                                   Object value, boolean isSelected, boolean hasFocus,
                                                                   int row, int column) {
//                        if (row % 2 == 0) {
//                            setBackground(Color.white); //设置奇数行底色
//                        } else if (row % 2 == 1) {
//                            setBackground(new Color(206, 231, 255)); //设置偶数行底色
//                        }
//                        if (table.getValueAt(row, 2).equals("true")) {
//                            setBackground(Color.red); 
//                        }
                        //如果需要设置某一个Cell颜色，需要加上column过滤条件即可
                        return super.getTableCellRendererComponent(table, value,
                                isSelected, hasFocus, row, column);
                    }
                };
                for (int i = 0; i < ActionTable.getColumnCount(); i++) {
                    if(i==2){
                    ActionTable.getColumn(ActionTable.getColumnName(i)).setCellRenderer(tcr);
                    }
                }
        
        this.updateActionListToTable(ActionTable);
        
        final ScheduledFuture<?> timeHandler = worldTime.scheduleAtFixedRate(new Runnable() {
            long startTime = System.currentTimeMillis() + 1000;
            JTable tab  = ActionTable;
            @Override
            public void run() {
                
                long endTime = System.currentTimeMillis();
                //结束计时
                long currentCollapsedTime = (endTime - startTime);
                Log("Running Time"+currentCollapsedTime);
                if(executeList.isEmpty()){
                    Log("Finished Running!");
                    worldTime.shutdown();
                }
                //Run the Application
//                Action tmp = executeList.get(0);
                for (Action a : executeList){
                    //高亮
                    
//                    Log(Arrays.toString(a.getP().getEq().toArray()));
                    
                    if(!a.isActive){
                        
                        
                        if(currentCollapsedTime >=  a.getStartTime()){
                            
                            if(!a.getReverse()){
                                a.getP().run(a.getP().getSpeed()*a.getSpeed()/100);
                            }
                            else {
                                a.getP().revertrun(a.getP().getSpeed()*a.getSpeed()/100);
                            }
                            
                            Log("Pump :"+ a.getP().getName()+"running with speed : "+ a.getP().getSpeed()*a.getSpeed()/100);
//                            Log("running Action :" + a.getSeq());
                            a.isActive = true;
                            tab.setValueAt("true", a.getSeq(), 2);
                            
                        }
                        ////
                    }
                    
                    if(currentCollapsedTime >= a.getEndTime()){
                            Log("Quit running Action :" + a.getSeq());
                            a.getP().shutdown();
                            
                            a.isActive = false;
                            tab.setValueAt("false", a.getSeq(), 2);
                            
                            int i = executeList.indexOf(a);
                            executeList.remove(a);
                            try {
                                executeList.add(i,a.getP().getEq().remove());
                                Log("XXXXXXX");
//                                Log(Arrays.toString(executeList.toArray()));
                                break;
                            }catch (Exception e){
                                Log("YYYYYYYYY");
//                                e.printStackTrace();
                                break;
                            }
//
                    
                    }
                
                }
            
            }
            
            

        },0,10,TimeUnit.MILLISECONDS );
        for(Action a : this.actionList){
           a.isActive = false;
       }
       
        for (Pump p :pumpList){
            p.shutdown();
        }
        this.updateActionListToTable(ActionTable);
        
       
       this.jButton10.setEnabled(true);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void pumpTypeBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pumpTypeBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pumpTypeBoxActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        
        this.ActionConfiguationMainPage.setVisible(false);
        this.PumpconfigMainFrame.setVisible(true);
        
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed

        deleteAction(ActionTable);
        Log("selected Action deleted! ");
        Log("Actions : "+Arrays.toString(this.actionList.toArray()));
        this.updateActionListToTable(ActionTable);
    }//GEN-LAST:event_jButton12ActionPerformed


    ////////////////private functions./////////////////////////////////
    void deleteAction(JTable tab){
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        if(tab.getSelectedRow()!= -1){
            int seq = Integer.parseInt((String)model.getValueAt(tab.getSelectedRow(),0));
            //delete from action list 
            for(int i=0 ; i < this.actionList.size();i++){
                Action a = this.actionList.get(i);
                if( a.getSeq() == seq){//更新之后的所有seq number 位seq-1
                   for(int j = i+1;j<this.actionList.size();j++){
                       Action s = this.actionList.get(j);
                       s.setSeq(s.getSeq()-1);
                   }
                    System.out.println(a.getP().getAq().toString());
                    a.getP().getAq().remove(a);
                    System.out.println(a.getP().getAq().toString());
                    this.actionList.remove(a);

                }
            }
            
        }
        return ;
    }
    private void deleteActionOnClick(java.awt.event.ActionEvent evt , JTable tab) {
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        if(tab.getSelectedRow()!= -1){
            model.removeRow(tab.getSelectedRow());
        }
    } 
    //向table里添加一个type
    private void addTypeToTable( JTable tab, PumpType t){
        ArrayList<String> content = new ArrayList<String>();
        content.add(t.getName());
        content.add(t.toString());
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        model.addRow(content.toArray());
    }
    
    private void mapTypeListToTable(JTable tab , ArrayList<PumpType> tl){
        this.clearTableContent(tab);
        for(PumpType t : tl){
            addTypeToTable(tab,t);
        }
    }
    
    ///@Parameter this function we add content of pump p to the jTable tab 
    private void addPumpToPumpTable(JTable tab, Pump p){
        ArrayList<String> content = new ArrayList<String>();
        content.add(p.getName());
        content.add(p.toString());
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        model.addRow(content.toArray());
        //add结束之后从pinlist里删除对应的针脚并更新Pinlist
//        System.out.println("add Pump to table");
//        Log("p.name: "+ p.getName() +" " + p.pinNumber1 + " " + p.pinNumber2 +"now being deleted from list");
//        System.out.println("Avaliable Pins :"+ Arrays.toString(this.pinList.toArray()));
    
//        if(pinList.contains(p.getPinNumber1())){
//        this.pinList.remove((Integer)p.pinNumber1);
//        }
////        System.out.println("Avaliable Pins :"+ Arrays.toString(this.pinList.toArray()));
//        if(pinList.contains(p.getPinNumber2())){
//            this.pinList.remove((Integer)p.pinNumber2);
//        System.out.println("Avaliable Pins :"+ Arrays.toString(this.pinList.toArray()));
        
    }
    //从table里删除一个type
    private void deleteTypeFromTable(java.awt.event.ActionEvent evt , JTable tab){
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        //从表格删除row
        if(tab.getSelectedRow()!= -1){
            String tName =(String) model.getValueAt(tab.getSelectedRow(),0);
            int in = findTypeByName(tName);
            if(in == -1){
                Log("can't find type remove anyway"+ tName);
                 model.removeRow(tab.getSelectedRow());
                return ;
            }
//            PumpType t = typelist.get(in);
            
            typelist.remove(in);
            model.removeRow(tab.getSelectedRow());
        }
    }
    //return the type-index
    private int findTypeByName(String str){
        if(str == ""|| str == null){
            System.out.println("can't find the pump the given pump name is null");
            return -1;
        }
        for(int i=0 ; i < typelist.size();i++){
            PumpType t = typelist.get(i);
            if( t.getName().equals(str) ){
                return i;
            }
        }
        return -1;
    }

    
    
    private void deletePumpFromTable( JTable tab){
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        //从表格删除row
        if(tab.getSelectedRow()!= -1){
        //从pumplist里删除
//        Log("TABLE DELETE ROW"+tab.getSelectedRow());
            String pName =(String) model.getValueAt(tab.getSelectedRow(),0);
            //remove my index
            try{
            int in = this.findPumpByName(pName);
            if(in == -1){
                System.out.println("can't find the pump ,no pump"+pName+ "exist!" );
                return ;
            }
            //释放可用针脚，检查pumplist
            Log("pump: "+pName+" deleted");
            Pump pump = this.pumpList.get(in);
            if(!pumpList.contains((Integer)pump.getPinNumber1())) {
                this.pinList.add((Integer)pump.getPinNumber1());
            }
            if(!pumpList.contains((Integer)pump.getPinNumber2())) {
                this.pinList.add((Integer)pump.getPinNumber2());
            }
            Collections.sort(pinList);
            
//            Log("Avaliable Pins :"+ Arrays.toString(this.pinList.toArray()));
            
            //remove from pump .remove from table
            this.pumpList.remove(in);
            showPumpList();
            model.removeRow(tab.getSelectedRow());
            
            //update  两个combobox的值
            this.mapPinListToComboBox(pumpPin1);
            this.mapPinListToComboBox(pumpPin2);
             }catch( Exception e){ 
            String message = "no selection";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
            }
        }
    }
    
    // 在pumplist里找pump
    //return的值是-1则没找到否则return pumpindex
    private int findPumpByName(String str) throws Exception{
        if(str.equals("")|| str == null){
            System.out.println("can't find the pump the given pump name is null");
            return -1;
        }
        for(int i=0 ; i < this.pumpList.size();i++){
            Pump p = this.pumpList.get(i);
            if( p.getName().equals(str) ){
                return i;
            }
        }
        return -1;
    }

    
    
    private void jButton12MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton12MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton12MouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        this.deletePumpFromTable( this.PumpTableInPumpPage);
    }//GEN-LAST:event_jButton3ActionPerformed
    private void Log(String str){
        System.out.println(str);
    }
    //Adding Pump Event
    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        //pump attr
        String pType = (String)this.pumpTypeBox.getSelectedItem();
        if(pType.equals("select")){
             String message = "please select a pumptype!";
             javax.swing.JOptionPane.showMessageDialog(this, message);
             return ;
        }
        int pts = findTypeByName(pType);
        if(pts == -1){
            String message = "type don't exist! (Invalid)!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        String pName = "";

        if(pumpNameField.getText() == null || pumpNameField.getText().equals("")){
             Log("no pump name input");
             String message = "PumpName should't be Empty!";
             javax.swing.JOptionPane.showMessageDialog(this, message);
             return ;
        }
        //若name那栏是空则显示popupmessage
        else {
            
             pName = this.pumpNameField.getText();
        }
        //defalut pin 0 1
        int pin1 = 0,pin2 = 1;
        
//        pin1 = Integer.parseInt((String)this.pumpPin1.getSelectedItem());
//        pin2 = Integer.parseInt((String)this.pumpPin2.getSelectedItem());
        
        //监听两个pin
        if (this.pin1Label.getText() == "" || this.pin2Label.getText() == "" ){
            //此处跳出"please select both pin"
            String message = "please select both pin!";
             javax.swing.JOptionPane.showMessageDialog(this, message);
             return;
        }
        if(this.pin1Label.getText() != "" && this.pin2Label.getText() != "" ){
            pin1 = Integer.parseInt(this.pin1Label.getText().substring(3));
            pin2 = Integer.parseInt(this.pin2Label.getText().substring(3));
        }
        
        //generate a new Pump Obj
        //生成默认速度为100 的Pump
//        Pump newPump = new Pump(pName,pType,pin1,pin2);
        //生成默认速度为读条的 Pump
        PumpType pt = typelist.get(pts);

        Pump newPump = new Pump(pName,pt,pumpSpeed.getValue(),pin1,pin2);
        
        addToPumpList(newPump);
        //DEBUG
//        System.out.println("A pump is added to the PumpList ! ");
       //update avalible pinList
       
        //add pump to the pumplist on the right 
        //show in the list
        // 滚轴装载table
//        JScrollPane jsp = new JScrollPane(this.PumpTableInPumpPage);
        this.mapPumplistToTable(this.PumpTableInPumpPage);
////清空左边所有值 ,更新两个pin list
        
        resetAllPumpConfig();
        
////////////refresh pumplists/////////
//        this.pumpPin1.removeAllItems();
//        this.pumpPin2.removeAllItems();
//        
//        pumpPin1.addItem("select");
//        pumpPin2.addItem("select");
//        for(int i = 0 ; i< this.pinList.size();i++){
//            pumpPin1.addItem(""+this.pinList.get(i));
//            pumpPin2.addItem(""+this.pinList.get(i));
//        }
//        
//        this.pin1Label.setText("select");
//        this.pin2Label.setText("select");
        this.mapPinListToComboBox(pumpPin1);
        this.mapPinListToComboBox(pumpPin2);
    }//GEN-LAST:event_jButton15ActionPerformed
    void addToPumpList(Pump p){
        // 添加时检查是否重名
        for(Pump pl : this.pumpList){
            if(p.getName().equals(pl.getName()) ){
                String message = "The pump name is already existed, please change one!";
                javax.swing.JOptionPane.showMessageDialog(this, message);
                return ;
            }
        
        }
        this.pumpList.add(p);
        this.showPinList();
        this.pinList.remove((Integer)p.getPinNumber1());
        this.showPinList();
        this.pinList.remove((Integer)p.getPinNumber2());
        this.showPinList();
    }

//添加pump之后重置左边参数
    private void resetAllPumpConfig(){
        this.pumpNameField.setText("");
        //根据pumplist更新pinlist 此处保证pumplist和pinlist同步
        this.updatePinList();
        this.showPinList();
    }
    /////两个combobox互相的listener
    private void pumpPin1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_pumpPin1ItemStateChanged
        try{
            if(evt.getStateChange() == java.awt.event.ItemEvent.SELECTED){
                //如果选择pin1 则更新pin2
                if(evt.getItem().toString() != ""){
//                    System.out.println("bp1");
                    ArrayList<Integer> inBox2 = (ArrayList<Integer>)this.pinList.clone();
                    Integer in = (Integer)Integer.parseInt((String)this.pumpPin1.getSelectedItem());
                    inBox2.remove(in);
//                    System.out.println(Arrays.toString(inBox2.toArray()));
                    int pin2 = Integer.parseInt(this.pin2Label.getText().substring(3));
                    this.pumpPin2.removeAllItems();
                    
                    pumpPin2.addItem("");
//                    System.out.println("Pin1 selected: "+evt.getItem().toString());
                    for(int i = 0 ; i< inBox2.size();i++){
                        pumpPin2.addItem(""+inBox2.get(i));
                    }
                    this.pin1Label.setText("-> "+evt.getItem().toString());
                }
            }
        }
        catch(Exception e ){
            
        }
    }//GEN-LAST:event_pumpPin1ItemStateChanged

    private void pumpPin2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_pumpPin2ItemStateChanged
         try{
             if(evt.getStateChange() == java.awt.event.ItemEvent.SELECTED){
                 
                 if(evt.getItem().toString() != ""){
                     
                    ArrayList<Integer> inBox1 = (ArrayList<Integer>)this.pinList.clone();
                    Integer in = (Integer)Integer.parseInt((String)this.pumpPin2.getSelectedItem());
                    inBox1.remove(in);
//                    System.out.println("Pin2 selected: "+evt.getItem().toString());
                    int pin1 = Integer.parseInt(this.pin1Label.getText().substring(3));
                    this.pumpPin1.removeAllItems();
                    pumpPin1.addItem("");
                    for(int i = 0 ; i< inBox1.size();i++){
                        pumpPin1.addItem(""+inBox1.get(i));
                    }
                    this.pin2Label.setText("-> "+evt.getItem().toString());
                 }

            }
        }
        catch(Exception e ){
            
        }
    }//GEN-LAST:event_pumpPin2ItemStateChanged

    ///save&add the Action to the Action List
    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed

        
        String pName = (String)this.PumpComboBox.getSelectedItem();
        try {
        int in = this.findPumpByName(pName);
            if(in == -1){
                System.out.println("can't find the pump ,no pump "+pName+ " exist!" );
                return ;
            }
            //释放可用针脚，检查pumplist
            Pump p = this.pumpList.get(in);
            String startt = startTimeInput.getText();
            String endt = endTimeInput.getText();
           //TODO 检查startt和endt的格式是否满足 "mm:ss:SSS" 如果不满足则弹窗
            System.out.println("TP1");
             System.out.println(p.toString());
//            Log("startTimeStr:"+startt);
//            Log("endTimeStr:"+endt);
            long startTime = timeTolong(startt);
            long endTime = timeTolong(endt);
//            Log("startTime:"+startTime);
//            Log("endTime:"+endTime);
            
        int speed = pumpActionSpeed.getValue();
            System.out.println("TP2");
        //利用pump生成Action
        Action t = new Action ( this.actionList.size(),
                startTime,
                endTime,
                speed,
                p,
                this.actionReversed.isSelected());
        
        System.out.println("TP3");

        this.actionList.add(t);
        Log("A new Action is added to the actionlist! ");
        showActionList();
        updateActionListToTable(this.ActionTable);
        }catch (Exception e ){
            String message = "input false";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            this.PumpActionPageNew.setVisible(false);
            return;
        }
        this.PumpActionPageNew.setVisible(false);
    }//GEN-LAST:event_jButton13ActionPerformed

    private long timeTolong(String str) throws ParseException {
        long out = 0;
        String[] arrOfStr = str.split(":", 0); 

        out = Long.parseLong(arrOfStr[0])*60000;
        out += Long.parseLong(arrOfStr[1])*1000;
        out += Long.parseLong(arrOfStr[2]);
        return out;
    }
    private String longToTimeString(long time) throws ParseException {
        StringBuffer buff = new StringBuffer();
        int min = (int) time / 60000;
        int secm = (int)time % 60000;
        int sec = secm / 1000;
        int msec = secm % 1000;
        buff.append(String.format("%02d", min));
        buff.append(":");
        buff.append(String.format("%02d", sec));
        buff.append(":");
        buff.append(String.format("%03d", msec));
        return buff.toString();
    }
    
    
    void updateActionListToTable(JTable tab){
        
        clearTableContent(tab);
        DefaultTableModel model = (DefaultTableModel) tab.getModel();
        for(Action a : this.actionList){
            ArrayList<String> content = new ArrayList<String>();
            content.add(""+a.getSeq());
            content.add(a.toString());
            content.add(""+a.isActive);
            model.addRow(content.toArray());
        }
    }
    
    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        // TODO add your handling code here:
        this.PumpActionPageNew.setVisible(false);
        
    }//GEN-LAST:event_jButton16ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        //隐藏typepage
        this.PumpTypePage.setVisible(false);
        //显示pumppage
        this.PumpconfigMainFrame.setVisible(true);
        //更新typelist
        this.mapTypelistToComboBox(typelist, this.pumpTypeBox);
        this.loadPumpconfigFrame();
        showTypeList();
        //TODO更新
        //删除pumpableInPumpPage里被删掉的pumptype
        
        
        
    }//GEN-LAST:event_jButton14ActionPerformed
    void loadTypeListToCombobox( JComboBox<String> box){
        DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        box.setModel(model);
        model.removeAllElements();
        
        for(int i = 0 ; i < this.typelist.size();i++){
            model.addElement(typelist.get(i).getName());
        }
    }
    
    
    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
         
        //错误判断如果有inputfield为null则弹窗，然后停止
         if(typefield.getText() == null || typefield.getText().equals("")
                 ||feqField.getText() == null || feqField.getText().equals("")
                 ||minspeedField.getText() == null || minspeedField.getText().equals("")){
             Log("null String input!");
             String message = "null String Input (Invalid)!";
             javax.swing.JOptionPane.showMessageDialog(this, message);
             return ;
        }
        PumpType p = new PumpType(this.typefield.getText(), Integer.parseInt(this.feqField.getText())
                 , Integer.parseInt(this.minspeedField.getText()) );
        this.typelist.add(p);
       // 更新list到table'
//       this.addTypeToTable(pListInTypepage,p);
        Log("add a Pump Type"+ p.getName()+" to the type List");
//        Log("Avaliavle Types:" + Arrays.toString(this.typelist.toArray()));
        this.mapTypeListToTable(pListInTypepage, typelist);


       this.typefield.setText("");
       this.feqField.setText("");
       this.minspeedField.setText("");
       showTypeList();
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        // TODO add your handling code here:
        // 进入typeconfig界面
        this.PumpTypePage.setVisible(true);

        clearTableContent(pListInTypepage);
        for(PumpType t : typelist){
            ArrayList<String> content = new ArrayList<String>();
            content.add(t.getName());
            content.add(t.toString());
            DefaultTableModel model = (DefaultTableModel) pListInTypepage.getModel();
            model.addRow(content.toArray());
        }

    }//GEN-LAST:event_jButton19ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        this.deleteTypeFromTable(evt, pListInTypepage);

        
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
       //暂停当前所有pump的动作
       //暂停所有的pumpthread
       if(worldTime!=null){
        worldTime.shutdown();
        }
       for(Action a : this.actionList){
           a.isActive = false;
       }
       
        for (Pump p :pumpList){
            p.shutdown();
        }
        this.updateActionListToTable(ActionTable);
       
       
    }//GEN-LAST:event_jButton20ActionPerformed

    private void pumpSpeedStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pumpSpeedStateChanged
        
        this.speedDisplay.setText(""+pumpSpeed.getValue());
    }//GEN-LAST:event_pumpSpeedStateChanged

    private void reversButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reversButtonActionPerformed
        if(reversButton.isSelected()) {
            reversButton.setText("Reverse");
        }else{
            reversButton.setText("Normal");
        }

    }//GEN-LAST:event_reversButtonActionPerformed

    private void expertSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_expertSliderStateChanged
        this.speedDisplayExpert.setText(""+expertSlider.getValue());
        try{
        DefaultTableModel model = (DefaultTableModel) PumpListInExpertMode.getModel();
        String pn =((String) model.getValueAt(PumpListInExpertMode.getSelectedRow(), 1));

        int in = findPumpByName(pn);
        if (in == -1) {
            String message = "current pump not exist!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
//        Log("bp 1");
        Pump p = pumpList.get(in);
        
        if(!this.runButton.isEnabled()){
            
            if(!this.reversButton.isSelected()){
//                int speed = p.getType().getMinSpeed()+((p.getType().getMinSpeed()+ p.getType().getRange()) * expertSlider.getValue() /100) ;
                p.run(expertSlider.getValue() );
            }
            else {
                p.revertrun(expertSlider.getValue());
            }
            
//            Log(p.getName()+ speed);
//            Log("bp 2");
        }
        }catch( Exception e){ 
            String message = "no selection";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        
        
        
    }//GEN-LAST:event_expertSliderStateChanged

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
        //获得pump对象
        try{
           
           for (Pump ps : pumpList){
               ps.shutdown();
//                Log("pump"+ps.getName()+"now stop!");
           }
//            String message = "Pause all pumps!";
//            javax.swing.JOptionPane.showMessageDialog(this, message);
           //enable  run / stop button
           this.runButton.setEnabled(true);
           this.Stopbtn.setEnabled(true);
           
           this.updatepumpListOnExpertTable();
           
        }catch( Exception e){ 
            String message = "no selection";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        
    }//GEN-LAST:event_jButton21ActionPerformed

    private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
        //读取到config   并重新赋值所有的list
        String out = "";
        try{
            JFileChooser chooser = new JFileChooser();
            //update -------add filefilter
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Json file(.json)","json");
            chooser.setFileFilter(filter);
            //jsonparse转化为Actionlist
            int value = chooser.showOpenDialog(ActionConfiguationMainPage);


            if(value == JFileChooser.APPROVE_OPTION){
                File file = chooser.getSelectedFile();
                StringBuffer buffer = new StringBuffer();
                
                FileInputStream fis = new FileInputStream(file);
                InputStreamReader isr = new InputStreamReader(fis,"GBK");
                Reader in = new BufferedReader(isr);
                int i ;
                while ((i = in.read()) > -1){
                    buffer.append((char) i);
                }
                in.close();
                //                Log(buffer.toString());
                out = buffer.toString();

            }
        }catch (IOException e){
            e.printStackTrace();
        }
        Log(out);
//        try {
//            Util.parseJsontoConfig(out);
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }



        Configuation con = null;
        try {
//            con = Util.parseJsontoConfig(out);

        if(!out.equals("")) {
            con = Util.parseJsontoConfig(out);


            typelist = con.getTypes();
            pumpList = con.getPumps();
            actionList = con.getActions();

        }
        } catch (Exception e) {
            this.Log("Input pull , parse cancel! ");
        }



            //清空table
            clearTableContent(ActionTable);

            //根据con更新所有table显示到list里


            showTypeList();
            showPumpList();
            showActionList();

            this.mapTypeListToTable(this.pListInTypepage, typelist);
            //安排slider
            setTS(pumpSpeed);
            loadPumpconfigFrame();

            //updateTab
            mapPumplistToTable(PumpListInActionPage);
            updateActionListToTable(ActionTable);



    }//GEN-LAST:event_jMenuItem14ActionPerformed

//    private <T> void updateTableFromList(JTable tab , List<T> list){
        //update all the table
//        for (T i  : list) {
//            ArrayList<String> content = new ArrayList<String>();
//            content.add("" + i.getSeq());
//            content.add(t.toString());
//            DefaultTableModel model = (DefaultTableModel) ActionTable.getModel();
//            model.addRow(content.toArray());
//        }
//TODO 把list所有的值显示在tab上
//    }

    private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed
        //保存config
        //将jsonstring保存为文件
        JFileChooser chooser = new JFileChooser();
        //update -------add filefilter
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Json file(.json)","json");
        chooser.setFileFilter(filter);


        Configuation config = new Configuation("Config",typelist,pumpList,actionList);

//        Log(config.getName());
//        Log(Arrays.toString(config.getTypes().toArray()));
//        Log(Arrays.toString(config.getPumps().toArray()));
//        Log(Arrays.toString(config.getActions().toArray()));
        
        String out =  Util.objToJsonString(config);
//        Log(out);

        
        int value = chooser.showSaveDialog(ActionConfiguationMainPage);
        if(value == JFileChooser.APPROVE_OPTION){
            try{
                File newFile = chooser.getSelectedFile();
                if(!newFile.exists()){
                    newFile.createNewFile();
                }
                //add extensions
                String fname = newFile.getName();
                if(fname.indexOf(".json") == -1){
//                    Log("add extensions");
                    newFile = new File(chooser.getCurrentDirectory(),fname+".json");
                }
                FileOutputStream outputStream = new FileOutputStream(newFile);
                outputStream.write(out.getBytes());
                outputStream.close();

                String message = "configuration saved!";
                javax.swing.JOptionPane.showMessageDialog(this, message);
                this.PumpActionPageNewLoop.setVisible(false);
                return;

            }catch (Exception e ){
                e.printStackTrace();
            }
        }

    }//GEN-LAST:event_jMenuItem15ActionPerformed

    private void endTimeInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endTimeInputActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_endTimeInputActionPerformed

    private void pumpActionSpeedStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pumpActionSpeedStateChanged
        // TODO add your handling code here:
        
        this.pumpActionSpeedDisplay.setText(""+pumpActionSpeed.getValue());
    }//GEN-LAST:event_pumpActionSpeedStateChanged

    private void endTimeInput1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endTimeInput1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_endTimeInput1ActionPerformed

    private void pumpActionSpeed1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pumpActionSpeed1StateChanged
         this.pumpActionSpeedDisplay1.setText(""+pumpActionSpeed1.getValue());
    }//GEN-LAST:event_pumpActionSpeed1StateChanged

    private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
        this.PumpActionPageNewLoop.setVisible(false);

    }//GEN-LAST:event_jButton22ActionPerformed

    private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
        
        String pName = (String)this.PumpComboBox1.getSelectedItem();
        try {
        int in = this.findPumpByName(pName);
            if(in == -1){
                System.out.println("can't find the pump ,no pump "+pName+ " exist!" );
                return ;
            }
            //释放可用针脚，检查pumplist
            Pump p = this.pumpList.get(in);
            
            String startt = startTimeInput1.getText();
            String endt = endTimeInput1.getText();
            String runInt = runInterval.getText();
            String stopInt = stopInterval.getText();
           //TODO 检查startt和endt的格式是否满足 "mm:ss:SSS" 如果不满足则弹窗

//            Log("startTimeStr:"+startt);
//            Log("endTimeStr:"+endt);
            long startTime = timeTolong(startt);
            long endTime = timeTolong(endt);
            long runt = timeTolong(runInt);
            long stopt = timeTolong(stopInt);
//            Log("startTime:"+startTime);
//            Log("endTime:"+endTime);
            
        int speed = pumpActionSpeed1.getValue();
        
        //利用pump生成Action
        long tmp = startTime;
        while( tmp <= endTime ){
            Action t = new Action ( this.actionList.size(),
                    tmp,
                    tmp+runt,
                    speed,
                    p,
                    this.actionReversed.isSelected());

            this.actionList.add(t);
            tmp += (runt+stopt);
        }
        showActionList();
        updateActionListToTable(this.ActionTable);
        }catch (Exception e ){
            String message = "input false";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            this.PumpActionPageNewLoop.setVisible(false);
            return;
        }
        this.PumpActionPageNewLoop.setVisible(false);
        
    }//GEN-LAST:event_jButton23ActionPerformed

    private void actionReversed1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionReversed1ActionPerformed
        // TODO add your handling code here:
        if(this.actionReversed1.isSelected()){
            this.actionReversed1.setForeground(Color.RED);
        }
        else {
            this.actionReversed1.setForeground(Color.BLACK);
        }
    }//GEN-LAST:event_actionReversed1ActionPerformed

    private void stopIntervalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopIntervalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_stopIntervalActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
       this.PumpActionPageNewLoop.setVisible(true);
        // 更新pumplist in combobox、
        this.PumpComboBox1.removeAllItems();
        
        for(int i = 0 ; i< this.pumpList.size();i++){
             this.PumpComboBox1.addItem(""+pumpList.get(i).getName());
        }
        this.startTimeInput1.setText("00:00:000");
        this.endTimeInput1.setText("00:20:000");
        this.runInterval.setText("00:01:000");
        this.stopInterval.setText("00:01:000");
        
        
    }//GEN-LAST:event_jButton5ActionPerformed

    private void actionReversedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionReversedActionPerformed
              if(this.actionReversed.isSelected()){
            this.actionReversed.setForeground(Color.RED);
        }
        else {
            this.actionReversed.setForeground(Color.BLACK);
        }
    }//GEN-LAST:event_actionReversedActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
      
        this.actionList.clear();
        this.updateActionListToTable(ActionTable);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
       
        
        DefaultTableModel model = (DefaultTableModel) ActionTable.getModel();
        if(ActionTable.getSelectedRow()!= -1){
             this.PumpActionEditPage.setVisible(true);
            this.PumpComboBox2.removeAllItems();
            int seq = Integer . parseInt ((String)model.getValueAt(ActionTable.getSelectedRow(),0));

            //delete from action list 
            for(int i=0 ; i < this.actionList.size();i++){
                Action a = this.actionList.get(i);
                try{
                    if( a.getSeq() == seq){
                      
                    this.PumpComboBox2.addItem(""+a.getP().getName());
                    for(int j = 0 ; j< this.pumpList.size();j++){
                        if(!pumpList.get(j).equals(a.getP())){
                           this.PumpComboBox2.addItem(""+pumpList.get(j).getName());
                        }
                    }
                    startTimeInput2.setText(this.longToTimeString(a.getStartTime()));
                    endTimeInput2.setText(this.longToTimeString(a.getEndTime()));
                    pumpActionSpeed2.setValue(a.getSpeed());
                    if(a.getReverse()){
                        this.actionReversed2.setSelected(true);
                    }else
                    this.actionReversed2.setSelected(false);
                    }
                }catch (Exception e){
                    
                }}
         }
        else{
            String message = "input false";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }   
            
        
        
        
    }//GEN-LAST:event_jButton11ActionPerformed

    private void pumpActionSpeed2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pumpActionSpeed2StateChanged
         this.pumpActionSpeedDisplay2.setText(""+pumpActionSpeed2.getValue());
    }//GEN-LAST:event_pumpActionSpeed2StateChanged

    private void actionReversed2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionReversed2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_actionReversed2ActionPerformed

    private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
        this.PumpActionEditPage.setVisible(false);
    }//GEN-LAST:event_jButton24ActionPerformed

    private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton25ActionPerformed
       DefaultTableModel model = (DefaultTableModel) ActionTable.getModel();
       
        if(ActionTable.getSelectedRow()!= -1){
            int seq = Integer . parseInt ((String)model.getValueAt(ActionTable.getSelectedRow(),0));

            //delete from action list 
            for(int i=0 ; i < this.actionList.size();i++){
                Action a = this.actionList.get(i);
                if( a.getSeq() == seq){
                try {    
                    String pname = (String)this.PumpComboBox2.getSelectedItem();
                    Log(pname + "selected!");
                int in = this.findPumpByName(pname);
                    if(in == -1){
                        this.PumpActionEditPage.setVisible(false);
                        return ;
                    }
                
                    long startTime = timeTolong(startTimeInput2.getText());
                    long endTime = timeTolong(endTimeInput2.getText());
                    int speed = pumpActionSpeed2.getValue();

                Action t = new Action ( i,
                        startTime,
                        endTime,
                        speed,
                        this.pumpList.get(in),
                        this.actionReversed2.isSelected());
                actionList.set(i, t);
                Log("action Edited!");
                showActionList();
                updateActionListToTable(this.ActionTable);
                }catch (Exception e ){
                    String message = "input false";
                    javax.swing.JOptionPane.showMessageDialog(this, message);
                    this.PumpActionEditPage.setVisible(false);
                    return;
                }
                this.PumpActionEditPage.setVisible(false);
                return;
                }
            }
            this.PumpActionEditPage.setVisible(false);
        }else{
            String message = "please select an action";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            this.PumpActionEditPage.setVisible(false);
            return;
        }
    }//GEN-LAST:event_jButton25ActionPerformed

    private void ActionTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ActionTableMouseClicked
         DefaultTableModel model = (DefaultTableModel) ActionTable.getModel();
        if(ActionTable.getSelectedRow()!= -1){
            String str = (String)model.getValueAt(ActionTable.getSelectedRow(),1);
            ActionDisplay.setText(str);
        }

    }//GEN-LAST:event_ActionTableMouseClicked

    private void StopbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StopbtnActionPerformed
       
        if(PumpListInExpertMode.getSelectedRow()== -1 ){
            String message = "please select a pump!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        try{
        DefaultTableModel model = (DefaultTableModel) PumpListInExpertMode.getModel();
        int selectedRow = PumpListInExpertMode.getSelectedRow();
        String pn =((String) model.getValueAt(selectedRow, 1));

        int in = findPumpByName(pn);
        if (in == -1) {
            String message = "current pump not exist!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        Pump p = pumpList.get(in);
        p.shutdown();
        p.isActive = false;
        Log("stop pump!"+ p.getName());
        
        this.updatepumpListOnExpertTable();
        runButton.setEnabled(true);
        
            
        PumpListInExpertMode.changeSelection(selectedRow, 0, false, false);
        
        
        
        }catch( Exception e){ 
            String message = "no selection";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }

    }//GEN-LAST:event_StopbtnActionPerformed

    private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed
        
        if(PumpListInExpertMode.getSelectedRow()== -1 ){
            String message = "please select a pump!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        try{
        DefaultTableModel model = (DefaultTableModel) PumpListInExpertMode.getModel();
        int selectedRow = PumpListInExpertMode.getSelectedRow();
        String pn =((String) model.getValueAt(selectedRow, 1));

        int in = findPumpByName(pn);
        if (in == -1) {
            String message = "current pump not exist!";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }
        
        Pump p = pumpList.get(in);
        
            if(!reversButton.isSelected()){
                p.run(expertSlider.getValue());
                
            }
            else {
                p.revertrun(expertSlider.getValue());
            }
            
            p.isActive = true;
            this.updatepumpListOnExpertTable();
            this.runButton.setEnabled(false);
            
            PumpListInExpertMode.changeSelection(selectedRow, 0, false, false);
            
        
        }catch( Exception e){ 
            String message = "no selection";
            javax.swing.JOptionPane.showMessageDialog(this, message);
            return;
        }

    }//GEN-LAST:event_runButtonActionPerformed

    private void PumpListInExpertModeMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PumpListInExpertModeMousePressed
        DefaultTableModel model = (DefaultTableModel) PumpListInExpertMode.getModel();
        if(PumpListInExpertMode.getSelectedRow()!= -1){
            String str = (String)model.getValueAt(PumpListInExpertMode.getSelectedRow(),3);
            if(str == "true"){
                this.runButton.setEnabled(false);
            }
            else if(str == "false"){
                this.runButton.setEnabled(true);
            }
            
        }
    }//GEN-LAST:event_PumpListInExpertModeMousePressed

    private void PumpListInExpertModeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PumpListInExpertModeMouseClicked
        
        
    }//GEN-LAST:event_PumpListInExpertModeMouseClicked

    private void mapTypelistToComboBox(ArrayList<PumpType> list ,javax.swing.JComboBox<String> box){
//    System.out.println("Avaliable Pins :"+ Arrays.toString(pinList.toArray())+ "in combox"+box.toString());
    box.removeAllItems();
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
    box.setModel(model);
    model.addElement("select");

        for (int j = 0; j < list.size(); j++) {
            model.addElement(""+list.get(j).getName());
        }
    }
    
    //根据现有的针脚map到jcombobox box上
    private void mapPinListToComboBox(javax.swing.JComboBox<String> box){
//    System.out.println("Avaliable Pins :"+ Arrays.toString(pinList.toArray())+ "in combox"+box.toString());
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
    box.setModel(model);
    model.addElement("select");
        for (int j = 0; j < pinList.size(); j++) {
            model.addElement(""+pinList.get(j));
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }

            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
        
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFrame ActionConfiguationMainPage;
    private javax.swing.JLabel ActionDisplay;
    private javax.swing.JFrame ActionExpertMode;
    private javax.swing.JTable ActionTable;
    private javax.swing.JPanel AddBumpBar2;
    private javax.swing.JPanel BumpBar1;
    private javax.swing.JPanel BumpBar2;
    private javax.swing.JFrame FileChooser;
    private javax.swing.JFileChooser Load;
    private javax.swing.JFrame PumpActionEditPage;
    private javax.swing.JFrame PumpActionPageNew;
    private javax.swing.JFrame PumpActionPageNewLoop;
    private javax.swing.JComboBox<String> PumpComboBox;
    private javax.swing.JComboBox<String> PumpComboBox1;
    private javax.swing.JComboBox<String> PumpComboBox2;
    private javax.swing.JTable PumpListInActionPage;
    private javax.swing.JTable PumpListInExpertMode;
    private javax.swing.JTable PumpTableInPumpPage;
    private javax.swing.JFrame PumpTypePage;
    private javax.swing.JFrame PumpconfigMainFrame;
    private javax.swing.JFileChooser Save;
    private javax.swing.JPanel SinglePumpAction;
    private javax.swing.JPanel SinglePumpAction1;
    private javax.swing.JPanel SinglePumpAction2;
    private javax.swing.JButton Stopbtn;
    private javax.swing.JToggleButton actionReversed;
    private javax.swing.JToggleButton actionReversed1;
    private javax.swing.JToggleButton actionReversed2;
    private javax.swing.JTextField endTimeInput;
    private javax.swing.JTextField endTimeInput1;
    private javax.swing.JTextField endTimeInput2;
    private javax.swing.JSlider expertSlider;
    private javax.swing.JTextField feqField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTabbedPane jTabbedPane3;
    private javax.swing.JTextField minspeedField;
    private javax.swing.JTable pListInTypepage;
    private javax.swing.JLabel pin1Label;
    private javax.swing.JLabel pin2Label;
    private javax.swing.JSlider pumpActionSpeed;
    private javax.swing.JSlider pumpActionSpeed1;
    private javax.swing.JSlider pumpActionSpeed2;
    private javax.swing.JLabel pumpActionSpeedDisplay;
    private javax.swing.JLabel pumpActionSpeedDisplay1;
    private javax.swing.JLabel pumpActionSpeedDisplay2;
    private javax.swing.JTextField pumpNameField;
    private javax.swing.JComboBox<String> pumpPin1;
    private javax.swing.JComboBox<String> pumpPin2;
    private javax.swing.JSlider pumpSpeed;
    private javax.swing.JComboBox<String> pumpTypeBox;
    private javax.swing.JToggleButton reversButton;
    private javax.swing.JButton runButton;
    private javax.swing.JTextField runInterval;
    private javax.swing.JLabel speedDisplay;
    private javax.swing.JLabel speedDisplayExpert;
    private javax.swing.JTextField startTimeInput;
    private javax.swing.JTextField startTimeInput1;
    private javax.swing.JTextField startTimeInput2;
    private javax.swing.JTextField stopInterval;
    private javax.swing.JTextField typefield;
    // End of variables declaration//GEN-END:variables

    
    ////starter scenes
    //selfDefined Vars
    ArrayList<Integer> pinList = new ArrayList<Integer>() ;
    ArrayList<Pump> pumpList = new ArrayList<Pump>() ;

    ArrayList<Action> actionList = new ArrayList<Action>();
    
    ArrayList<PumpType> typelist = new ArrayList<PumpType>();

    private void showPumpList(){
        Log("Pumps : " +  Arrays.toString(pumpList.toArray()));
    }
    private void showActionList() {
        Log("Actions : " + Arrays.toString(actionList.toArray()));
    }
    private void showTypeList() {
        Log("Types : " + Arrays.toString(typelist.toArray()));
    }
    private void showPinList() {
        Log("Pins : " + Arrays.toString(pinList.toArray()));
    }

    private void loadPumpconfigFrame() {
         setTS(pumpSpeed);
//        System.out.println("pin loaded !");
//        System.out.println("Avaliable Pins :"+ Arrays.toString(this.pinList.toArray()));
//使得pinlist最新
        this.updatePinList();
        //然后更新两个combobox
        this.mapPinListToComboBox(this.pumpPin1);
        this.mapPinListToComboBox(this.pumpPin2);                    
        this.pin1Label.setText("-> "+0);
        this.pin2Label.setText("-> "+1);

        this.mapPumplistToTable(PumpTableInPumpPage);
        
        mapTypelistToComboBox(typelist,pumpTypeBox);
    }
    
    private void mapPumplistToTable(javax.swing.JTable tab){
        this.clearTableContent(tab);
        for(Pump p : this.pumpList){
            this.addPumpToPumpTable(tab, p);
        }
        
    }
            
    //根据pumplist移除所有已经被占用的针脚留下可用的针脚
    private void updatePinList(){
        pinList.clear();
        
        //OnLoad Pin List
        for (int i = 0 ; i < 32 ; i++){
            pinList.add((Integer)i);
        }
        
        Iterator iter = pumpList.iterator();
        while (iter.hasNext()){
            Pump p = (Pump)iter.next();
            this.pinList.remove((Integer)p.getPinNumber1());
            this.pinList.remove((Integer)p.getPinNumber2());
        }

    }


    
    
    
    
    
}
